package com.wmh.baseservice.admin.pojo.vo.role;

import com.wmh.baseservice.admin.entity.AdRole;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.PositiveOrZero;

/**
 * @author 谢骏
 * @date 2023/8/10 11:35
 **/
@ApiModel(value="基础字段")
@Data
@Accessors(chain = true)
public class BaseFields {

    @NotBlank(message = "未提交名称")
    private String name;

    @NotNull(message = "未提交可开放账号数量")
    @PositiveOrZero(message = "可开放账号数量在 0~99999 之间")
    @Max(value = 99999,message = "可开放账号数量在 0~99999 之间")
    private Integer accountNum;

    private String remark;


    public static AdRole buildEntity(Long id, BaseFields fields){
        AdRole adRole = new AdRole();
        adRole.setId(id);
        adRole.setRoleName(fields.getName());
        adRole.setAccountNum(fields.getAccountNum());
        adRole.setRemark(fields.getRemark());
        adRole.setUpdateTime(null);
        return adRole;
    }
}
